home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
pshdir1a.zip
/
PUSHDIR.LST
< prev
next >
Wrap
File List
|
1988-12-22
|
22KB
|
317 lines
Turbo Assembler Version 1.0 12-22-88 23:23:19 Page 1
PUSHDIR.ASM
1 main group code
2 0000 code segment public para 'code'
3 assume cs:main
4
5 org 100h ;.COM file
6
7 0100 E9 020F BEGIN: jmp START ;program starts here
8 ; db "Copyright 1986 Ziff-Davis Publishing Co.",1Ah
9 ; Changes made on 12/22/88 by Mike Williams
10 ; 1. Support command line parm to also CHDIR
11 ; 2. If path string refers to a drive, log that drive
12 ;
13 0103 50 55 53 48 44 49 52 + signature db 'PUSHDIR VERSION 1.a'
14 20 56 45 52 53 49 4F +
15 4E 20 31 2E 61
16 = 0013 lengthsignature = $ - signature
17
18 0116 ???????? savedint16 dd ? ;old int 16h vector
19
20 011A 011Cr nextpush dw offset main:push1dir ;next place to save a dir
21 011C 43*(00) push1dir db 67 dup (0) ;storage for a saved dir
22 015F 43*(00) push2dir db 67 dup (0) ;more storage
23 01A2 43*(00) push3dir db 67 dup (0) ;more storage
24 01E5 43*(00) push4dir db 67 dup (0) ;more storage
25 0228 43*(00) push5dir db 67 dup (0) ;more storage
26 026B 43*(00) push6dir db 67 dup (0) ;last storage
27
28 ;up to here must be EXACTLY identical in both PUSHDIR and POPDIR so that
29 ;popdir can know how to access the memory space reserved by the first
30 ;pushdir.
31
32 ;myint16 is an interrupt handler chained onto the existing interrupt handler.
33 ;it is used to find out if PUSHDIR is already installed and if it is, where
34 ;is it located? It works by adding another function to int 16h. To use it
35 ;ax = 7788h, bx = 7789h, and ds:si points to the signature string. If any one
36 ;of these conditions is not true, then the int 16h call is passed onto the
37 ;old routine without doing anything. If they are all true, then we switch
38 ;ax and bx and return ds = code segment (cs) of the interrupt handler.
39
40 02AE myint16 proc far
41
42 02AE 9C pushf ;save flags
43 02AF 3D 7788 cmp ax,7788h ;possible signature request ?
44 02B2 74 06 je CHECKSIG ;yes
45 NOTSIG:
46 02B4 9D popf ;no - recover flags
47 02B5 2E: FF 2E 0116r jmp cs:[savedint16] ;go to old routine as normal
48
49 CHECKSIG:
50 02BA 81 FB 7789 cmp bx,7789h ;possible signature request ?
51 02BE 75 F4 jne NOTSIG ;no
52
53 ;ax and bx were correct for a signature request
54 ;now see if ds:si was pointing to the signature string
55 ;the whole idea of the signature is that is has to be
56 ;totally unique so no other program could possibly use the same one.
57
58 02C0 06 push es ;save the registers we will use
59 02C1 57 push di
Turbo Assembler Version 1.0 12-22-88 23:23:19 Page 2
PUSHDIR.ASM
60 02C2 51 push cx
61 02C3 BF 0103r mov di,offset main:signature ;address of the signature
62 02C6 B9 0013 mov cx,lengthsignature ;length of the signature
63 02C9 F3> A6 repe cmpsb ;does string at ds:si match es:di ?
64 02CB 59 pop cx ;recover all registers we used
65 02CC 5F pop di
66 02CD 07 pop es
67 02CE 75 E4 jne NOTSIG ;no, not correct signature
68
69 ;yes, it was a signature request so return ds equal to the current code
70 ;segment so subsequent pushdir's and popdir's know where the original
71 ;is located.
72
73 02D0 0E push cs
74 02D1 1F pop ds ;set ds = cs
75 02D2 93 xchg ax,bx ;flip these two so we know that
76 ;ds is being returned
77 02D3 9D popf ;recover original flags
78 02D4 CF iret ;return back to the program
79 ;that called the int 16h
80
81 02D5 myint16 endp
82
83 endresident label byte ;label marking the end of the
84 ;code to remain resident
85
86 ;code after here will not remain resident
87
88 02D5 01 install db 1 ;0 = already installed, 1 = not installed
89
90 02D6 45 72 72 6F 72 20 72 + abortmsg db 'Error reading the current directory.$'
91 65 61 64 69 6E 67 20 +
92 74 68 65 20 63 75 72 +
93 72 65 6E 74 20 64 69 +
94 72 65 63 74 6F 72 79 +
95 2E 24
96 02FB 50 55 53 48 44 49 52 + installmsg db 'PUSHDIR 1.a installed.$'
97 20 31 2E 61 20 69 6E +
98 73 74 61 6C 6C 65 64 +
99 2E 24
100
101 0312 START:
102 0312 FB sti ;turn interrupts on
103
104 ;first check to see if PUSHDIR is already installed
105
106 0313 B8 7788 mov ax,7788h ;signature request
107 0316 BB 7789 mov bx,7789h ;signature request
108 0319 BE 0103r mov si,offset main:signature ;point to signature
109 031C CD 16 int 16h ;is it installed ?
110
111 assume ds:nothing
112
113 031E 81 FB 7788 cmp bx,7788h ;were ax and bx switched ?
114 0322 75 0B